Skip to content

feat(templates): validate and warn on duplicate block definitions - #24

Merged
XtremeOwnageDotCom merged 1 commit into
mainfrom
feat/validate-template-blocks
Jul 29, 2026
Merged

feat(templates): validate and warn on duplicate block definitions#24
XtremeOwnageDotCom merged 1 commit into
mainfrom
feat/validate-template-blocks

Conversation

@XtremeOwnageDotCom

Copy link
Copy Markdown
Contributor

Add TemplateBlockValidator to detect duplicate block definitions in theme template overrides (e.g., multiple {% block header %}). Duplicate blocks silently override, causing subtle bugs and confusing debugging.

The validator:

  • Parses template files using regex to extract block names
  • Warns (not errors) when duplicates are found
  • Is case-insensitive (blocks are case-insensitive in Scriban)
  • Integrates into TemplateEngine.GetTemplate() before parsing

This catches the issue at build time, preventing silent failures.

Includes 4 test cases covering: no duplicates, single duplicate, multiple duplicates, and case-insensitive matching.

All 356 tests pass.

What & why

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Refactor / chore

Checklist

  • dotnet format Netdocs.slnx --verify-no-changes passes
  • dotnet build Netdocs.slnx -c Release succeeds
  • dotnet test Netdocs.slnx -c Release passes
  • Added/updated tests for the change
  • Updated docs under docs-site/docs/** if behavior changed

Notes for reviewers

Add TemplateBlockValidator to detect duplicate block definitions in theme
template overrides (e.g., multiple `{% block header %}`). Duplicate blocks
silently override, causing subtle bugs and confusing debugging.

The validator:
- Parses template files using regex to extract block names
- Warns (not errors) when duplicates are found
- Is case-insensitive (blocks are case-insensitive in Scriban)
- Integrates into TemplateEngine.GetTemplate() before parsing

This catches the issue at build time, preventing silent failures.

Includes 4 test cases covering: no duplicates, single duplicate, multiple
duplicates, and case-insensitive matching.

All 356 tests pass.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@XtremeOwnageDotCom
XtremeOwnageDotCom merged commit 5433a11 into main Jul 29, 2026
1 check failed
@XtremeOwnageDotCom
XtremeOwnageDotCom deleted the feat/validate-template-blocks branch July 29, 2026 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant